package com.xzzz.irda.guardcat.core.metric.gc;


import java.io.Serializable;
import java.util.Date;

/**
 * 最后一次 GC 信息
 *
 * @author xzzz
 * @since 1.0.0
 */
public class LastGcInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * GC 的 id
     */
    private final Long id;

    /**
     * GC 开始时间
     */
    private final Date startTime;

    /**
     * GC 结束时间
     */
    private final Date endTime;

    /**
     * GC 持续时间
     */
    private final long duration;

    /**
     * GC 前内存使用情况
     */
    private final GcMemoryUsageInfo beforeGc;

    /**
     * GC 后内存使用情况
     */
    private final GcMemoryUsageInfo afterGc;


    public LastGcInfo(Long id, Date startTime, Date endTime, long duration, GcMemoryUsageInfo beforeGc, GcMemoryUsageInfo afterGc) {
        this.id = id;
        this.startTime = startTime;
        this.endTime = endTime;
        this.duration = duration;
        this.beforeGc = beforeGc;
        this.afterGc = afterGc;
    }

    public Long getId() {
        return id;
    }

    public Date getStartTime() {
        return startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public long getDuration() {
        return duration;
    }

    public GcMemoryUsageInfo getBeforeGc() {
        return beforeGc;
    }

    public GcMemoryUsageInfo getAfterGc() {
        return afterGc;
    }

    @Override
    public String toString() {
        return "最后一次 GC 信息{" +
                "id=" + id +
                ", 开始时间='" + startTime + '\'' +
                ", 结束时间='" + endTime + '\'' +
                ", GC 持续时长=" + duration + "毫秒" +
                ", GC 前内存信息=" + beforeGc +
                ", GC 后内存信息=" + afterGc +
                '}';
    }
}
